<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="130px">
      <el-form-item label="版本" prop="version" >
        <el-date-picker clearable size="small"
                        v-model="queryParams.version"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="退服版本日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['tietasystem:fadianjishilv:export']"
        >导出</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="tableData">
      <el-table-column label="地市" align="center" prop="cityName" />
      <el-table-column label="停电数量（有需求）" align="center" prop="toutageHasNums_b" />
      <el-table-column label="外部供电退服无停电告警（有需求）" align="center" prop="texternalHasNums_b" />
      <el-table-column label="外部供电退服无停电告警（无需求无证明）" align="center" prop="texternalNoNums_b" />
      <el-table-column label="停电且退服（有需求）" align="center" prop="ttingHasNums_y" />
      <el-table-column label="外部供电退服无停电告警（有需求）" align="center" prop="texternalHasNums_y" />
      <el-table-column label="停电且退服（无需求无证明）" align="center" prop="ttingNoNums_y" />
      <el-table-column label="外部供电退服无停电告警（无需求无证明）" align="center" prop="texternalNoNums_y" />
      <el-table-column label="发电需求总数" align="center" prop="btotal" />
      <el-table-column label="发电不及时数" align="center" prop="ytotal" />
      <el-table-column label="发电及时率" align="center" prop="rate" />
    </el-table>
  </div>
</template>

<script>
import {fadianjishilvlist,exportfadianjishilv} from "@/api/tietasystem/report/fadianjishilv";

export default {
  data() {
    return {
      columns: [
      ],
      tableData: [],
      // 显示搜索条件
      showSearch: true,
      // 查询参数
      queryParams: {
        version: null
      },
    }
  },
  // mounted() {
  //   this.tableData = [
  //     {cityName: '沈阳', toutageHasNums_b: '101', texternalHasNums_b: '102', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '大连', toutageHasNums_b: '201', texternalHasNums_b: '202', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '鞍山', toutageHasNums_b: '301', texternalHasNums_b: '302', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '抚顺', toutageHasNums_b: '401', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '本溪', toutageHasNums_b: '501', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '丹东', toutageHasNums_b: '601', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '锦州', toutageHasNums_b: '701', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '营口', toutageHasNums_b: '801', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '阜新', toutageHasNums_b: '901', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '辽阳', toutageHasNums_b: '1001', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '铁岭', toutageHasNums_b: '1101', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '朝阳', toutageHasNums_b: '1201', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '盘锦', toutageHasNums_b: '1301', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '葫芦岛', toutageHasNums_b: '1401', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //     {cityName: '总计', toutageHasNums_b: '1501', texternalHasNums_b: '402', texternalNoNums_b: '103', ttingHasNums_y: '104', texternalHasNums_y: '105', ttingNoNums_y: '106', texternalNoNums_y: '107', btotal: '108', ytotal: '109', toutageHasNums_b0: '110'},
  //   ];
  // },
  created() {
    // this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      fadianjishilvlist(this.queryParams).then(response => {
        this.tableData = response.rows;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$modal.confirm('是否确认导出数据项？').then(() => {
        this.exportLoading = true;
        return exportfadianjishilv(queryParams);
      }).then(response => {
        this.$download.name(response.msg);
        this.exportLoading = false;
      }).catch(() => {});
    },
  }
}
</script>
